package thing

import (
	"github.com/gin-gonic/gin"
	"iot-base/auth/api/logic"
	Log "iot-base/auth/logger"
	"iot-base/auth/types"
)

func GetService(c *gin.Context) {
	requestId, _ := c.Get("RequestId")
	uid := c.GetInt64("uid")
	resp := types.NewResult(c)
	var req types.ReqService
	if err := c.ShouldBind(&req); err != nil {
		Log.Log.Errorf("[%s] [%v] err:=%v", requestId, uid, err)
		resp.ErrorCode(types.ParamsError, err.Error())
		return
	}
	result, err := logic.NewThingLogic().GetThingService(req.ThingIds)
	if err != nil {
		resp.ErrorCode(types.Fail, err.Error())
		return
	}
	resp.Success(result)
}
